import fetch from 'common/src/utils/fetch';

function getReElectionFailtableList(data) {//学生、教务员登录查询不及格课程
    let url;
    if (data.studentId) {
        url = `/api/electionservice/retakeCourse/failedCourses?calendarId=${data.calendarId}&studentId=${data.studentId}`;
    } else {
        url = `/api/electionservice/retakeCourse/failedCourseList?calendarId=${data.calendarId}`
    }
    return fetch({
        url: url,
        method: 'get',

    });
}
// {"pageNum_":1,"pageSize_":20,"condition":{"calendarId":109,"keyWord":"","studentId":1893165}}
function getReElectionTableData(data) {//学生登录查询重修选课
    let url;
    if (data.condition && data.condition.studentId) {
        url = `/api/electionservice/retakeCourse/findRebuildCourses`
    } else {
        url = `/api/electionservice/retakeCourse/findRebuildCourseList`
    }
    return fetch({
        url: url,
        method: 'post',
        data
    });
}


function getReElectionRetireClass(data) {//退课选课

    return fetch({
        url: '/api/electionservice/retakeCourse/updateRebuildCourse',
        method: 'post',
        data

    });
}

function getReElectionSwitch(data) {//查询选课开关
    return fetch({
        url: '/api/electionservice/retakeCourse/getRetakeRule?calendarId=' + data + '&projectId=2',
        method: 'get',

    });
}/**
 * 查询重修选课学生信息
 */
function getReElectionStuInfo(data) {
    return fetch({
        url: `/api/electionservice/retakeCourse/findRebuildStu?calendarId=${data.calendarId}&studentId=${data.studentId}`,
        method: 'get'
    })

}
export default {
    getReElectionFailtableList,
    getReElectionTableData,
    getReElectionRetireClass,
    getReElectionSwitch,
    getReElectionStuInfo
};
